package main

const (
	HOST = "localhost"
	PORT = "8080"
)

func main()  {

	// 先建立和服务器的连接的socket，再通过socket建立Transport
	//socket, err := thrift.NewTSocket(net.JoinHostPort("127.0.0.1", "8080"))
	//if err != nil {
	//	fmt.Println("Error opening socket:", err)
	//	os.Exit(1)
	//}
	//transport := thrift.NewTFramedTransport(socket)
	//
	//// 创建二进制协议
	//protocol := thrift.NewTBinaryProtocolTransport(transport)
	//// 打开Transport，与服务器进行连接
	//if err := transport.Open(); err != nil {
	//	fmt.Fprintln(os.Stderr, "Error opening socket to "+"localhost"+":"+"9999", err)
	//	os.Exit(1)
	//}
	//defer transport.Close()

	//// 接口需要context，以便在长操作时用户可以取消RPC调用
	//ctx := context.Background()
	//
	//// 使用divmod服务
	//divmodProtocol := thrift.NewTMultiplexedProtocol(protocol, "PHPService")
	//// 创建代理客户端，使用TMultiplexedProtocol访问对应的服务
	//c := thrift.NewTStandardClient(divmodProtocol, divmodProtocol)

	//client := compute.NewDivModClient(c)
	//client := penngo.
	//res, err := client.DoDivMod(ctx, 100, 3)
	//if err != nil {
	//	fmt.Println(err)
	//	os.Exit(1)
	//}
	//fmt.Println(res)

	// 使用mulrange服务
	// 步骤与上面的相同
	//mulProtocol := thrift.NewTMultiplexedProtocol(protocol, "mulrange")
	//c = thrift.NewTStandardClient(mulProtocol, mulProtocol)
	//client2 := compute.NewMulRangeClient(c)
	//num, err := client2.BigRange(ctx, 100)
	//if err != nil {
	//	fmt.Println(err)
	//	os.Exit(1)
	//}
	//fmt.Println(num)


	//tSocket, err := thrift.NewTSocket(net.JoinHostPort(HOST, PORT))
	//if err != nil {
	//	log.Fatalln("tSocket error:", err)
	//}
	////TBinaryProtocol
	//var Protocol thrift.TProtocol =thrift.NewTBinaryProtocol(tSocket, true, true)
	////TMultiplexedProtocolNewTMultiplexedProtocol
	////NewTMultiplexedProtocol
	//tm:=thrift.NewTMultiplexedProtocol(Protocol,"PHPService")
	//
	//penngo.
	//
	// tSocket.Open()


	//multiplex = thrift.NewTMultiplexedProtocol(Protocol,"PHPService")
	//penngo.New

	//FaceService.Iface client = new FaceService.Client(multiplex);

	//transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
	//transport := transportFactory.GetTransport(tSocket)
	//protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	//
	//client :=penngo.NewPhpServiceClientFactory(transport, protocolFactory)
	////client := penngo.NewPhpServiceClientFactory(transport, protocolFactory)
	//
	//if err := transport.Open(); err != nil {
	//	log.Fatalln("Error opening:", HOST + ":" + PORT)
	//}
	//defer transport.Close()


	//data := example.Data{Text:"hello,world!"}
	//d, err := client.DoFormat(&data)
	//data := penngo.Message{"asdsad"}
	//d, err := client.Getphp(&data)
	//fmt.Println(d.Text)
}